/**
 * 设备页js
 */
angular.module('app.device', [
])

.config(function($stateProvider, $urlRouterProvider) {
	$stateProvider
	// 设备页
	.state('main.device', {
		url : '/device',
		templateUrl : 'app/device/device.html',
		controller : 'DeviceController'
	})
})

// 设备控制器
.controller('DeviceController', function($scope, DeviceService) {
	$scope.devicelist = DeviceService.getdevicelist();
	//$rootScope.buycount = ShoppingCartService.getcount();
	// 呼叫
	$scope.call = function(info) {
		//CallService.callservant($scope.rid, $scope.dtid, info);
	}
})


	.controller("AdvertiseController", ['$scope', 'advservice', 'advcontentservice', 'advproviderservice',
		function ($scope, advservice, advcontentservice, advproviderservice) {
		advservice.getadvbyall().$promise.then(function (data) {
			$scope.advs = data;
		});
		$scope.currentPage = 1;
		$scope.pageSize = 8;
		$scope.changeadv = function (id, advcontentid) {
			advcontentservice.getadvcontentbyid(advcontentid).$promise.then(function (data) {
				var adv = {};
				for (var i = 0; i < $scope.advs.length; i++) {
					if ($scope.advs[i].advid == id) {
						adv = $scope.advs[i];
						break;
					}
				}
				adv.advcontent = data.advcontent;
				//console.log(adv);
			})
		}
		$scope.changeadv1 = function (id, advspid) {
			advproviderservice.getadvproviderbyid(advspid).$promise.then(function (data) {
				var adv = {};
				for (var i = 0; i < $scope.advs.length; i++) {
					if ($scope.advs[i].advid == id) {
						adv = $scope.advs[i];
						break;
					}
				}
				adv.advspname = data.advspname;
				//console.log(adv);
			})
		}
	}])
;